package com.gmail.dmitryustimov.ms.observer.java7_anonymous_classes;

public class Subscriber {

    String name;
    Writer writer;

    public Subscriber(Writer writer, final String name) {
        this.name = name;
        this.writer = writer;
        writer.bookEventPublisher.subscribe(
                new SubscribeAction<Book>() {
                    public void process(Book book) {
                        System.out.println(name + " is processing: " + book);
                    }
                }
        );
        writer.articleEventPublisher.subscribe(
                new SubscribeAction<Article>() {
                    public void process(Article article) {
                        System.out.println(name + " is processing: " + article);
                    }
                }
        );
    }
}
